<!-- 统计服务 -->
<template>
  <div>
    <!-- 应用统计 -->
    <div class="data-card">
      <div class="title">应用统计</div>
      <ul class="count-list">
        <li class="count-data">
          <span class="label-tip">应用数</span>
          <span class="label">{{ appCount }}</span>
        </li>
        <li class="count-data">
          <span class="label-tip">功能数</span>
          <span class="label">{{ functionCount }}</span>
        </li>
        <li class="count-data">
          <span class="label-tip">账号数</span>
          <span class="label">{{ accountCountTotal }}</span>
        </li>
      </ul>
    </div>

    <!-- 权限设置 -->
    <div class="rbac-data-card">
      <div class="title">权限控制</div>
      <ul class="count-list">
        <li class="count-data">
          <span class="label-tip">用户组</span>
          <span class="label label-mini">{{ tenantCount }}</span>
        </li>
        <li class="count-data">
          <span class="label-tip">部门</span>
          <span class="label">{{ departmentCount }}</span>
        </li>
        <li class="count-data">
          <span class="label-tip">角色</span>
          <span class="label">{{ roleCount }}</span>
        </li>
        <li class="count-data">
          <span class="label-tip">用户数</span>
          <span class="label">{{ accountCount }}</span>
        </li>
      </ul>

      <div class="childAccount">
        <div>通用权限和集团权限配置说明</div>
      </div>

      <ul class="quickEntry">
        <li>
          <router-link to="/views/portal/ucenter/account/list">新建用户</router-link>
<!--          <router-link-->
<!--            title="新建用户"-->
<!--            href="#"-->
<!--            class="v3-4-29-btn v3-4-29-medium v3-4-29-btn-normal"-->
<!--            ><span class="v3-4-29-btn-helper">新建用户</span></router-link-->
<!--          >-->
        </li>
        <li>
          <router-link to="/views/portal/ucenter/department/list">新建用户组</router-link>
<!--          <a-->
<!--            title="新建用户组"-->
<!--            href="#"-->
<!--            class="v3-4-29-btn v3-4-29-medium v3-4-29-btn-normal"-->
<!--            ><span class="v3-4-29-btn-helper">新建用户组</span></a-->
<!--          >-->
        </li>
        <li>
          <router-link to="/views/portal/ucenter/role/list">添加权限</router-link>
<!--          <a-->
<!--            title="添加权限"-->
<!--            href="#"-->
<!--            class="v3-4-29-btn v3-4-29-medium v3-4-29-btn-normal"-->
<!--            ><span class="v3-4-29-btn-helper">添加权限</span></a-->
<!--          >-->
        </li>
        <li>
          <router-link to="/views/portal/ucenter/tenant/list">新建租户</router-link>
<!--          <a-->
<!--            title="新建自定义策略"-->
<!--            href="#"-->
<!--            class="v3-4-29-btn v3-4-29-medium v3-4-29-btn-normal"-->
<!--            ><span class="v3-4-29-btn-helper">新建租户</span></a-->
<!--          >-->
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import {getApplicationCount, getAuthorityCount} from "@/api/authority/Home";

export default {
  components: {},
  data() {
    return {
      appCount: 0,
      functionCount: 0,
      accountCountTotal: 0,
      tenantCount: 0,
      departmentCount: 0,
      roleCount: 0,
      accountCount: 0,
    };
  },
  mounted() {
    this.getApplicationCount();
    this.getAuthorityCount();
  },
  methods: {
    getAuthorityCount() {
      getAuthorityCount().then(res => {
        if (res.code === 200) {
          let data = res.data;
          this.tenantCount = data.tenantCount;
          this.departmentCount = data.departmentCount;
          this.roleCount = data.roleCount;
          this.accountCount = data.accountCount;
        }
      })
    },
    getApplicationCount() {
      getApplicationCount().then(res => {
        if (res.code === 200) {
          let data = res.data;
          this.appCount = data.appCount;
          this.functionCount = data.functionCount;
          this.accountCountTotal = data.accountCountTotal;
        }
      })
    },
  },
};
</script>

<style scoped lang="scss">
.data-card {
  border: 1px solid #e3e4e6;
  background: #fff;
  border-radius: 2px;
  padding: 20px;
  float: left;
  width: 100%;
  margin-bottom: 20px;

  .title {
    margin-top: 0px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 500;
  }

  ul.count-list {
    list-style: none;
    float: left;
    padding: 0px;
    margin: 0px;
    width: 100%;

    li.count-data {
      float: left;
      background: #f7f9fa;
      border-color: #f7f9fa;
      flex: 1;
      height: auto;
      position: relative;
      text-align: left;
      margin-right: 8px;
      padding: 12px;
      width: calc(33.33% - 8px);
      text-decoration: none;
      overflow: hidden;
      border-width: 1px;
      border-style: solid;
      border-radius: 2px;
      transition: all 0.1s linear;
      text-align: left;

      span.label-tip {
        width: 100%;
        float: left;
        font-size: 12px;
      }
      span.label {
        color: #333;
        display: block;
        line-height: 36px;
        font-size: 20px;
      }
    }
  }
}

.rbac-data-card {
  border: 1px solid #e3e4e6;
  background: #fff;
  border-radius: 2px;
  padding: 20px;
  float: left;
  width: 100%;
  margin-bottom: 20px;

  .title {
    margin-top: 0px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 500;
  }

  .childAccount {
    background: #f7f9fa;
    padding: 8px;
    color: #565050;
    word-break: break-all;
    font-size: 12px;
    margin-top: 20px;
    float: left;
    width: 100%;
    line-height: 15px;
  }

  ul.count-list {
    list-style: none;
    float: left;
    padding: 0px;
    margin: 0px;
    width: 100%;

    li.count-data {
      float: left;
      background: #f7f9fa;
      border-color: #f7f9fa;
      flex: 1;
      height: auto;
      position: relative;
      text-align: left;
      margin-right: 8px;
      padding: 12px;
      width: calc(25% - 8px);
      text-decoration: none;
      overflow: hidden;
      border-width: 1px;
      border-style: solid;
      border-radius: 2px;
      transition: all 0.1s linear;
      text-align: left;

      span.label-tip {
        width: 100%;
        float: left;
        font-size: 12px;
      }
      span.label {
        color: #333;
        display: block;
        line-height: 36px;
        font-size: 13px;
      }
    }
  }

  ul.quickEntry {
    display: flex;
    justify-content: space-between;
    padding: 0px;
    margin: 0px;
    float: left;
    width: 100%;
    font-size: 12px;
    margin-top: 20px;

    li {
      display: inline-block;
      flex-grow: 1;
      flex-basis: 0;
      flex-basis: 0;
      border: 1px solid #c0c6cc;
      text-align: center;
      margin-right: 5px;
      border-radius: 2px;
      font-size: 12px;
      font-weight: 600;
      color: #333;

      a {
        color: #333;
        cursor: pointer;
      }
    }
  }
}
</style>


